package com.hwl.demo5.factory;

import com.hwl.demo1.service.Operation;

/**
 * 工厂方法模式
 *
 * @author sentry
 * @since 2023-03-18
 */
public class OperationFactory {

    public static Operation createOperate(String operate) {
        switch (operate) {
            case "+":
            case "-":
            case "*":
            case "/":
                return new FactoryBasic().createOperation(operate);
            case "pow":
            case "log":
                return new FactoryAdvanced().createOperation(operate);
            default:
                throw new RuntimeException("暂不支持该操作符");
        }
    }

    public static void main(String[] args) {
        Operation log = OperationFactory.createOperate("pow");
        System.out.println(log.getResult(2, 3));
    }
}
